home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / vla / dir_vla / d.nfo < prev    next >
Text File  |  1993-09-15  |  5KB  |  158 lines

  1. 09-16-1993 
  2.  
  3.  
  4.     This is yet another small VLA tutorial.  This one deals (kinda) with 
  5. some of the odd, yet useful, DOS disk functions.
  6.  
  7. I'll just start by making note of some facts that I found useful:
  8.  
  9.   ■ When you enter a program, be it an EXE or a COM, ES = the PSP segment.
  10.     The ENVIRONMENT segment is found a offset 2ch in the PSP segment.
  11.      So to grab it you'd do:
  12.  
  13.         mov     ax,[es:2ch] ;ax now conains the ENVIRONMENT seg
  14.  
  15.      I didn't actually need to use this in this program, but it IS useful
  16.      for scanning for sound card settings and for finding where the 
  17.      command interperator is (COMSPEC=C:\COMMAND.COM)
  18.       All the entries are ASCIIZ strings.
  19.  
  20.   ■ The DTA, again whether you are in a COM or an EXE, begins at offset 80h
  21.     in the PSP. This is where your command line is initially, and is
  22.     also used as a work area by DOS for file searches.
  23.  
  24.     ■ You can relocate the DTA by using FN# 1Ah, INT 21h and setting
  25.       DS:DX to the new location.
  26.  
  27.     ■ FN# 2Fh, INT 21h returns the DTA address in ES:BX
  28.  
  29. Now the cool functions:
  30.  
  31.   ■ FN# 19h, Report current drive. 
  32.  
  33.       IN:   AH = 19h
  34.  
  35.      OUT:   AL = drive ID (0=A, 1=B, 2=C, etc.)
  36.  
  37.   ■ FN# 0Eh, Set current drive.
  38.      
  39.       IN:   AH = 0Eh
  40.             DL = drive ID (0=A, 1=B, 2=C, etc.)
  41.  
  42.      OUT:   AL = number of drives installed
  43.  
  44.      ■ To find out how many drives are installed, do this:
  45.  
  46.         mov     ah,19h
  47.         int     21h
  48.         mov     dl,al
  49.         mov     ah,0eh
  50.         int     21h
  51.                        ;al = # of installed drives
  52.  
  53.   ■ FN# 36h, Get disk free space.
  54.  
  55.       IN:   AH = 36h
  56.             DL = drive ID + 1, (0=current drive, 1=A, 2=B, 3=C, etc.)
  57.  
  58.      OUT:   AX = Sectors per Cluster
  59.             BX = Available cluster count
  60.             CX = Bytes per sector
  61.             DX = Total clusters
  62.  
  63.      ■ Total free space = AX * BX * CX
  64.  
  65.      ■ Total space (disk size) = AX * CX * DX
  66.  
  67.      ■ Percentage of disk available = (BX * 100) / DX
  68.  
  69.         ■ I used the above formula to get the percentage, but then used
  70.           a small bit of cleverness to extend the precision out to 3 places.
  71.  
  72.             P = BX * 100 / DX
  73.              
  74.             Precision =  (BX * 100 * 1000 / DX) - (P * 1000)
  75.  
  76.             Then print out P and then a decimal point and then print the
  77.              precision.
  78.   
  79.   ■ FN# 4Eh, Find first matching file.
  80.  
  81.       IN:   AH = 4Eh
  82.             CX = attributes to match
  83.             DS:DX = pointer to filespec ASCIIZ string
  84.  
  85.      OUT:   AX = return code,  2 = file not found, 
  86.                               18 = no more files to be found
  87.  
  88.         ■ This function fills in the DTA area with a 43 byte structure:
  89.             
  90.             STRUC DTA
  91.                 stuff   db  21 dup (?)  ;dos work area for finding next file
  92.                 Attr    db  ?           ;attribute of file
  93.                 Time    dw  ?           ;time stamp
  94.                 Date    dw  ?           ;date stamp
  95.                 Size    dd  ?           ;size of the file
  96.                 Fname   db  13 dup (0)  ;ASCIIZ filename (no dot if no EXT)
  97.             ENDS
  98.  
  99.         ■ Attribute:
  100.             bit 1 = Read Only
  101.                 2 = Hidden
  102.                 3 = System
  103.                 4 = Volume label
  104.                 5 = Subdirectory
  105.                 6 = Archive
  106.               7-8 = Unused
  107.  
  108.              The only flag of any importance is the volume label. If you set
  109.             this flag, the search will ONLY search for directories. If it is
  110.             not set, it will match all normal files plus any that have the
  111.             attributes set in any combination.  For example:
  112.  
  113.              A attribute flag of 00110111b in cx will find ALL files and 
  114.             subdirectories.  A flag of 00011000b will find ONLY directories.
  115.             00000001b will find all normal files and any file with READ ONLY
  116.             set, but no other attributes.
  117.  
  118.         ■ Time stamp:
  119.  
  120.             Time = Hour * 2048 + Minutes * 32 + seconds / 2
  121.  
  122.              Hour = Time >> 11
  123.  
  124.              Minute = (Time >> 5) & 63
  125.  
  126.              Seconds = (Time << 1) & 63
  127.  
  128.         ■ Date stamp:
  129.  
  130.             Date = (Year - 1980) * 512 + Month * 32 + Day
  131.  
  132.              Year = 1980 + (Date >> 9)
  133.  
  134.              Month = (Date >> 5) & 16 
  135.              
  136.              Day = Date & 32
  137.  
  138.         ■ Filename:
  139.  
  140.             An ASCIIZ string, just like any other filename.  If there is no
  141.             extension, there is no "."
  142.   
  143.   ■ FN# 4Fh, Find next matching file.
  144.  
  145.       IN:   AH = 4Fh
  146.             CX = attributes to match
  147.             DS:DX = pointer to filespec ASCIIZ string
  148.  
  149.      OUT:   AX = return code, 18 = no more files to be found
  150.  
  151.      ■ This just continues the file search started by FN# 4Eh
  152.   
  153.  
  154. Well, that's just about it... Oh, well, that's an end to this doc.
  155.  
  156. Draeden /VLA
  157.  
  158.